home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form frmDBMan
- Caption = "Database Management"
- ClientHeight = 2925
- ClientLeft = 1065
- ClientTop = 1710
- ClientWidth = 5415
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H80000008&
- LinkTopic = "Form1"
- PaletteMode = 1 'UseZOrder
- ScaleHeight = 2925
- ScaleWidth = 5415
- Begin VB.TextBox txtCountry
- DataField = "country"
- DataSource = "datCities"
- Height = 285
- Left = 2040
- TabIndex = 6
- Top = 1560
- Width = 2895
- End
- Begin VB.TextBox txtPop2015
- DataField = "pop2015"
- DataSource = "datCities"
- Height = 285
- Left = 2040
- TabIndex = 8
- Top = 2520
- Width = 2895
- End
- Begin VB.TextBox txtPop1995
- DataField = "pop1995"
- DataSource = "datCities"
- Height = 285
- Left = 2040
- TabIndex = 7
- Top = 2040
- Width = 2895
- End
- Begin VB.TextBox txtCity
- DataField = "city"
- DataSource = "datCities"
- Height = 285
- Left = 2040
- TabIndex = 5
- Top = 1080
- Width = 2895
- End
- Begin VB.Data datCities
- Caption = "Large World Cities"
- Connect = "Access"
- DatabaseName = "MEGACTY1.MDB"
- DefaultCursorType= 0 'DefaultCursor
- DefaultType = 2 'UseODBC
- Exclusive = 0 'False
- Height = 300
- Left = 480
- Options = 0
- ReadOnly = 0 'False
- RecordsetType = 1 'Dynaset
- RecordSource = "Cities"
- Top = 600
- Width = 4455
- End
- Begin VB.CommandButton cmdQuit
- Caption = "Quit"
- Height = 375
- Left = 4080
- TabIndex = 3
- Top = 120
- Width = 1215
- End
- Begin VB.CommandButton cmdSearch
- Caption = "Search"
- Height = 375
- Left = 2760
- TabIndex = 2
- Top = 120
- Width = 1215
- End
- Begin VB.CommandButton cmdDelete
- Caption = "Delete"
- Height = 375
- Left = 1440
- TabIndex = 1
- Top = 120
- Width = 1215
- End
- Begin VB.CommandButton cmdAdd
- Caption = "Add"
- Height = 375
- Left = 120
- TabIndex = 0
- Top = 120
- Width = 1215
- End
- Begin VB.Label lblCountry
- Caption = "Country:"
- Height = 255
- Left = 1200
- TabIndex = 11
- Top = 1560
- Width = 735
- End
- Begin VB.Label lblPop2015
- Alignment = 1 'Right Justify
- Caption = "2015 Population:"
- Height = 255
- Left = 480
- TabIndex = 10
- Top = 2520
- Width = 1455
- End
- Begin VB.Label lblPop1995
- Alignment = 1 'Right Justify
- Caption = "1995 Population:"
- Height = 255
- Left = 480
- TabIndex = 9
- Top = 2040
- Width = 1455
- End
- Begin VB.Label lblCity
- Alignment = 1 'Right Justify
- Caption = "City:"
- Height = 255
- Left = 1560
- TabIndex = 4
- Top = 1080
- Width = 375
- End
- Attribute VB_Name = "frmDBMan"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Private Sub cmdAdd_Click()
- 'Add a new record
- datCities.Recordset.AddNew
- txtCity.SetFocus 'Data must be entered and a new record moved to
- End Sub
- Private Sub cmdDelete_Click()
- 'Delete the currently displayed record
- datCities.Recordset.Delete
- 'Move so that user sees deleted record disappear
- datCities.Recordset.MoveNext
- If datCities.Recordset.EOF Then
- datCities.Recordset.MovePrevious
- End If
- End Sub
- Private Sub cmdQuit_Click()
- End
- End Sub
- Private Sub cmdSearch_Click()
- Dim strSearchFor As String, foundFlag As Boolean
- 'Search for the city specified by the user
- strSearchFor = UCase(InputBox("Name of city to find:"))
- If Len(strSearchFor) > 0 Then
- datCities.Recordset.MoveFirst
- foundFlag = False
- Do While (Not foundFlag) And (Not datCities.Recordset.EOF)
- If UCase(datCities.Recordset.Fields("City").Value) = strSearchFor Then
- foundFlag = True
- Else
- datCities.Recordset.MoveNext
- End If
- Loop
- If Not foundFlag Then
- MsgBox "Unable to locate requested city.", , "Not Found"
- datCities.Recordset.MoveLast 'move so that EOF is no longer true
- End If
- Else
- MsgBox "Must enter a city.", , ""
- End If
- End Sub
- Private Sub datCities_Validate(Action As Integer, Save As Integer)
- 'Prevent a user from adding a city of population under 1 millio
- Dim strMsg As String
- If Val(txtPop1995) < 1 Then
- If Not datCities.Recordset.EOF And Not datCities.Recordset.BOF Then
- strMsg = "We only allow cities having a population of " & _
- "at least one million."
- MsgBox strMsg, , "City too small!"
- Action = 0
- End If
- End If
- End Sub
- Private Sub Form_Load()
- 'Look for the data base in the same folder as the program
- datCities.DatabaseName = App.Path & "\MEGACTY1.MDB"
- End Sub
-